﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace BlogTruyen
{
    public partial class Setting : PhoneApplicationPage
    {
        Dictionary<string, string> ReadTypes =  new Dictionary<string, string>() { 
                {"Reading1.xaml","Cuộn xuống - có zoom"},
                {"Reading2.xaml","Lật trang - không zoom"},
                //{"Reading3.xaml","Lật trang - có zoom - dễ dis"},
            };
        Boolean pageLoaded;
        public Setting()
        {
            InitializeComponent();
            lpReadType.ItemsSource = ReadTypes;
            lpReadType.SelectedItem = ReadTypes.Single(t => t.Key == Models.Config.GetValue("readtype"));
            lpReadType.SelectionChanged+=lpReadType_SelectionChanged;
        }


        private void lpReadType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                var selected = ((KeyValuePair<string, string>)e.AddedItems[0]);
                Models.Config.SetValue("readtype", selected.Key);
            }
            
        }
    }
}